use std::{
    borrow::BorrowMut,
    sync::{Arc, Mutex},
    thread,
    time::{Duration, Instant},
};

use tklog::{
    debug, debugs, error, errors, fatal, fatals, info, infos, sync::Logger, tklog::LEVEL, trace,
    traces, warn, warns, Format, LOG, MODE,
};

fn main() {
    println!("Hello, world!");
    log_init();
    testlog();
}

fn log_init() {
    LOG.set_console(true)
        .set_level(LEVEL::Trace)
        .set_format(Format::LevelFlag | Format::Date | Format::Time | Format::LongFileName)
        .set_cutmode_by_size("tklog.txt", 10000, 10, true)
        .set_formatter("{level} {time} {file}: {message}\n");
}

#[derive(Debug)]
pub struct Test{
    str:String,
    year:usize,
}

impl std::fmt::Display for Test{
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(format!("{:?}",self).as_str())
    }
}

fn testlog() {
    let test=Test{
        str: "todo!()".to_string(),
        year: 1,
    };

    log_init();
    trace!("trace>>>>",test );
    debug!("debug>>>>", "bbbbbbbbb", 1, 2, 3, 5);
    info!("info>>>>", "ccccccccc", 1, 2, 3, 5);
    warn!("warn>>>>", "dddddddddd", 1, 2, 3, 6);
    error!("error>>>>", "eeeeeeee", 1, 2, 3, 7);
    fatal!("fatal>>>>", "ffffffff", 1, 2, 3, 8);
    thread::sleep(Duration::from_secs(1))
}
